#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Purpose: Test project ui methods (saveas, etc.)
# Created: 10/19/2009
# $Id $
# Copyright (c) 2008,2009 by University College London
# Authors:
#  --<>
#
# This program is free software under the GPL (>=v2)
# Read the file COPYING coming with HydroPlatform for details.

import unittest

import support
support.init_hydroplatform()

from hydroplatform.model import network as nt
from hydroplatform.ui.commands import saveas_project



class TestProjectMethods(unittest.TestCase):
    
    def setUp(self):
        self.session = support.get_dbsession()
        self.context = support.Context()        
        support.load_sample_network1(self.session)    
        
    def tearDown(self):
        pass
    
    def test_saveas_project(self):
        """
        FIXME : broken test as it fails during the call to open_project on 
        the last line of the saveas_project method. This will be solved when 
        the saveas_project method will be extracted to networkfun.
        """
        proj1 = self.session.query(nt.Project).first()
        self.context.session.hpproject = proj1
        self.context.session.dbsession = self.session
        
        saveas_project(self.context, "test_project")



if __name__=='__main__':
    unittest.main()